package com.huan.social.baidu.connect;

import com.huan.social.baidu.api.Baidu;
import com.huan.social.baidu.api.impl.BaiduTemplate;
import lombok.Getter;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

/**
 * 服务提供商
 *
 * @author huan.fu
 * @date 2018/9/27 - 17:20
 */
@Getter
public class BaiduServiceProvider extends AbstractOAuth2ServiceProvider<Baidu> {

	private String userInfoUrl;

	public BaiduServiceProvider(String clientId, String clientSecret, String userInfoUrl, String authorizeUrl, String accessTokenUrl) {
		super(new BaiduOauth2Template(clientId, clientSecret, authorizeUrl, accessTokenUrl));
		this.userInfoUrl = userInfoUrl;
	}

	@Override
	public Baidu getApi(String accessToken) {
		return new BaiduTemplate(accessToken, this.getUserInfoUrl());
	}
}
